% BASIC FLOWCHART STRUCTURE with subtasks
% DESCRIPTION: This file contains the basic structure and lower level
% subtasks required to build the algorithm in MATLAB
%
% 1) Obtain Data
% 2) Filtering / Pre-Processing
% 3) Processing
% 4) Baseline Filtering
% 5) Compare with Commands
% 6) Output to Chair

%% 1) Obtain Data
% Obtain Data from EEG and parse into buffers with time-stamps.
	% - Data in from Comma Separated Value or Tab Delimited value file.
	% - Create small window of values from a sample of the file for each node.
	% - Window is a certain length of time based on incoming time-stamps

%% 2) Filtering / Pre-Processing
% Filter the buffered data using FIR or Weighted Averaging. Other Pre-Processing tasks happen here.
	% - Window matrix of data is filtered using one of the above techniques
	% - Other Tasks

%% 3) Processing
% Acquire frequency spectrums of buffered data within EEG bandwidth using FFTs.
	% - Take FFT of each node array of window matrix
	% - Shift FFT data to within EEG bandwidth and store in matrix.
	% - Dimensions of FFT Matrix: Frequency x Node x Magnitude(the value for each element)

%% 4) Baseline Filtering
% Compare the filtered data with the baseline data to adjust for environmental variables.
	% - [This task is not as simple as an addition/subtraction and may require active analysis
	% - of frequency concentrations depending on the mental state of the user]

%% 5) Compare with Commands
% Check to see if signals are within tolerances when compared to command data-sets.
	% - Subtract the Command Matrices (which have been pre-recorded) from the FFT Matrices
	% - Test the results vs. a set of tolerances for each set.
	% - If the results meet the tolerance requirement for a particular command, send the corresponding signals to the chair. 
	% - If the results are particularly close (consistently) in some areas of a particular command matrix, adjust the values in question for that command. Do not send a signal.
	% - If the values are not close for a particular command, do not send that command. 

%% 6) Output to Chair
% Output commands to the wheelchair.
	% - EITHER: output signals straight from the Beagleboard (or other embedded computer)
	% - OR: send commands to a go-between controller for the chair 